<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>CMP Instruction</title>
<link href="../edit68k.css" rel="stylesheet" type="text/css">
</head>

<body>
<h1 class="heading">CMP Instruction<BR>
</h1>
<hr noshade></h1>
<BR>
<span class="text">CMP (CoMPare) compares a data register with an effective address. The flags are affected the same way as if the effective address was subtracted from the data register. None of the operands are changed. Often used with the Bcc instruction. An example:<BR>
<BR>
CMP D0,D1<BR>
BGT X1<BR>
<BR>
The program will branch to X1 if D1 is greater than D0, else the program will
continue.</span>
    <TABLE border=0 cellPadding=0 cellSpacing=0 width="100%">
  <TBODY>
    <TR>
      <TD width="24%" class="text">ADDRESS METHODS:</TD>
      <TD width="76%" class="text">Dn, An, (An), (An)+, -(An), x(An), x(An,xr.s), x.w, x.l, x(PC), x(PC,xr.s), #x</TD>
    </TR>
  </TBODY>
</TABLE>
<P class="text">DATA LENGTH: Byte, word, longword<BR>
    <BR>
  Byte can't be used when comparing to an address register.</P>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="67%">
  <TBODY>
    <TR>
      <TD width="15%" rowSpan=5 vAlign=top class="text">FLAGS:</TD>
      <TD width="85%" class="text">X - U</TD>
    </TR>
    <TR>
      <TD width="85%" class="text">N - S</TD>
    </TR>
    <TR>
      <TD width="85%" class="text">Z - S</TD>
    </TR>
    <TR>
      <TD width="85%" class="text">C - Set if a borrow was needed when subtracting, otherwise it is cleared.</TD>
    </TR>
    <TR>
      <TD width="85%" class="text">V - S</TD>
    </TR>
  </TBODY>
</TABLE>
<P><span class="text">SYNTAX: CMP &lt;ea&gt;,Dn<BR>
      <BR>
  There are four CMP instructions, CMP, CMPA, CMPI and CMPM. The compiler often chooses the right instruction, so you can write CMP all the time if you want.</span></P>
<P class="sourcecode"><span class="text">&nbsp;&nbsp; CMP&nbsp;&nbsp;&nbsp; #2,D0&nbsp;&nbsp;&nbsp; 
 
compares D0 to #2 and sets CCR flags accordingly</span></P>
</body>
</html>